package leetcode.code0404;

import leetcode.helper.tree.TreeNode;

public class Solution {

	int ans = 0;

	public int sumOfLeftLeaves(TreeNode root) {
		this.sum(root, false);
		return ans;
	}

	private void sum(TreeNode root, boolean b) {
		if (root.left == null && root.right == null) {
			if (b) {
				ans += root.val;
			}
			return;
		}
		if (root.left != null) {
			this.sum(root.left, true);
		}
		if (root.right != null) {
			this.sum(root.right, false);
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
